//
//  MySegueNone.m
//  EcmDoctor
//
//  Created by 张进 on 15/7/2.
//  Copyright (c) 2015年 张进. All rights reserved.
//

#import "SegueAnimationNone.h"

@implementation SegueAnimationNone

- (void)perform

{
    
//    UIViewController *source = self.sourceViewController;
//    UIViewController *destination = self.destinationViewController;
//    
//    [UIView animateWithDuration:0.1
//                          delay:0
//                        options:UIViewAnimationOptionCurveEaseOut
//                     animations:^(void) {}
//                     completion: ^(BOOL done) {
//                         // Properly present the new screen
//                         [source presentViewController:destination animated:NO completion:nil];
//                     }];
    
//    方法1
    UIViewController *current = self.sourceViewController;
    
    UIViewController *next = self.destinationViewController;

    [current.navigationController pushViewController:next animated:NO];
    
    
//    方法2
//    UIViewController* source = self.sourceViewController;
//    UIViewController* destination = self.destinationViewController;
//    
//    CGRect sourceFrame = source.view.frame;
//    sourceFrame.origin.x = -sourceFrame.size.width;
//    
//    CGRect destFrame = destination.view.frame;
//    destFrame.origin.x = destination.view.frame.size.width;
//    //destFrame.origin.x = 100;
//    //destination.view.frame = destFrame;
//    
//    destFrame.origin.x = 0;
//    [source.view.superview addSubview:destination.view];
//    [UIView animateWithDuration:3
//                     animations:^{
//                         source.view.frame = sourceFrame;
//                         //destination.view.frame = destFrame;
//                     }
//                     completion:^(BOOL finished) {
//                         //[source presentViewController:destination animated:NO completion:nil];
//                         [source.navigationController pushViewController:destination animated:NO];
//                     }];
    
    
//    方法3
//    UIViewController * svc = self.sourceViewController;
//    UIViewController * dvc = self.destinationViewController;
//    
//    [svc.navigationController.view addSubview:dvc.view];
//    [dvc.view setFrame:svc.view.frame];
//    [dvc.view setTransform:CGAffineTransformMakeScale(0.1, 0.1)];
//    [dvc.view setAlpha:0.0];
//    [UIView animateWithDuration:1.0
//                     animations:^{
//                         [dvc.view setTransform:CGAffineTransformMakeScale(1.0, 1.0)];
//                         [dvc.view setAlpha:1.0];
//                     }
//                     completion:^(BOOL finished) {
//                         //                         [dvc.view removeFromSuperview];
//                         
//                     }];
    
    
//    方法4
//    UIViewController *source = self.sourceViewController;
//    UIViewController *destination = self.destinationViewController;
//
//    // Create a UIImage with the contents of the destination
//    UIGraphicsBeginImageContext(destination.view.bounds.size);
//    [destination.view.layer renderInContext:UIGraphicsGetCurrentContext()];
//    UIImage *destinationImage = UIGraphicsGetImageFromCurrentImageContext();
//    UIGraphicsEndImageContext();
//    
//    // Add this image as a subview to the parent controller
//    UIImageView *destinationImageView = [[UIImageView alloc] initWithImage:destinationImage];
//    [source.parentViewController.view addSubview:destinationImageView];
//    
//    // Scale the image down and rotate it 180 degrees (upside down)
//    CGAffineTransform scaleTransform = CGAffineTransformMakeScale(0.1, 0.1);
//    CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(M_PI);
//    destinationImageView.transform = CGAffineTransformConcat(scaleTransform, rotateTransform);
//    
//    // Move the image outside the visible area
//    CGPoint oldCenter = destinationImageView.center;
//    CGPoint newCenter = CGPointMake(oldCenter.x - destinationImageView.bounds.size.width, oldCenter.y);
//    destinationImageView.center = newCenter;
//    
//    // Start the animation
//    [UIView animateWithDuration:0.1f
//                          delay:0
//                        options:UIViewAnimationOptionCurveEaseOut
//                     animations:^(void) {
////                         destinationImageView.transform = CGAffineTransformIdentity;
////                         destinationImageView.center = oldCenter;
//                     }
//                     completion: ^(BOOL done) {
//                         // Remove the image as we no longer need it
////                         [destinationImageView removeFromSuperview];
//                         
//                         // Properly present the new screen
//                         [source presentViewController:destination animated:NO completion:nil];
//                         //[source.navigationController pushViewController:destination animated:NO];
//                     }];
}

@end
